Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚮 Eliminate elementName method #27470

Merged
merged 1 commit into from
Mar 30, 2020
Merged

Conversation

jridgewell
Copy link
Contributor

It's equivalent to the Element's localName in every case we care about. Also eliminates a bit of constructor cruft from the CEv0 days.

It's equivalent to the Element's `localName` in every case we care
about. Also eliminates a bit of constructor cruft from the CEv0 days.
Copy link
Contributor

@kristoferbaxter kristoferbaxter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

self = super(self);
self.createdCallback();
return self;
/** */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does something complain when removing this empty comment?

Copy link

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Element.localName in the "no CE" polyfill case (IE 11)?

@jridgewell
Copy link
Contributor Author

What is Element.localName in the "no CE" polyfill case (IE 11)?

Excellent question, and one I hadn't tested. Thankfully, IE11 does the right thing and reports the lowercased name, like all the other browsers.

@jridgewell jridgewell merged commit fc69bcf into ampproject:master Mar 30, 2020
@jridgewell jridgewell deleted the elementName branch March 30, 2020 20:55
This was referenced Apr 8, 2020
jridgewell added a commit to jridgewell/amphtml that referenced this pull request Apr 15, 2020
This is a continuation of ampproject#25245. All of our Custom Elements extend from a common `CustomAmpElement` class, which itself extends from `HTMLElementPolyfill`. In ampproject#27470, I removed the `constructor` from `CustomAmpElement` class. But, because it's a subclass and must have a `constructor` that calls `super()`, Closure replaced it with a `constructor() { superClass.apply(this, arguments); }` when transpiling.

But, due to the same faulty inheritance chain described in ampproject#25245, `HTMLElementPolyfill` doesn't inherit an `apply` method! So doing `superClass.apply()` throws an error. 😭

This PR installs all important Function methods onto our polyfill, to be resilient to any future changes in the instance creation.
calebcordry added a commit that referenced this pull request Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants